<template>
  <div id="emptycarBox">
    <div class="top">
      <img src="./img/empty.png" alt="" />
      <p>您的购物车还是空的，赶紧行动吧！</p>
      <div @click="gohome">立即挑选</div>
    </div>
    <div class="recommendBox">
      <h4>为您推荐</h4>
      <div class="partsBox">
        <div
          class="parts"
          v-for="item in $store.state.cakeArr"
          :key="item.goods_id"
          @click="gogoodscontent(item.goods_id)"
        >
          <img :src="$store.state.url + item.goods_coverimg" alt="" />
          <div id="parts-text">
            <span>{{ item.goods_name }}</span>
            <p>￥{{ item.goods_price }}</p>
          </div>
          <span
            class="iconfont icon-gouwuche"
            id="addcarbtm"
            @click="changeisclickcar(item.goods_id)"
          ></span>
          <addCar v-if="$store.state.isclickcar">
            <template slot="cancel"
              ><span @click="changeisclickcar">取消</span></template
            >
          </addCar>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import addCar from "../addcar/addcar.vue";
export default {
  // name: "McakeEmptycar",
  components: { addCar },

  // directives: { DirectiveName },

  data() {
    return {};
  },

  mounted() {},

  methods: {
    changeisclickcar(goods_id) {
      // console.log(goods_id);
      this.$store.commit("changeGoodsid", goods_id);
      this.$store.commit("changeIsclickcar");
    },
    gohome() {
      this.$router.push("/");
    },
    gogoodscontent(goodsid) {
      this.$router.push({ path: `/goodscontent?id=${goodsid}` });
    },
  },
};
</script>
<style lang="scss" scoped>
#emptycarBox {
  width: 100%;
}
.top {
  width: 100%;
  height: 500px;
  line-height: 100px;
  text-align: center;
  background-color: #d1d1d1;
  margin-bottom: 20px;
  img {
    margin-top: 40px;
  }
  p {
    font-size: 30px;
    color: white;
  }
  div {
    width: 130px;
    height: 50px;
    background-color: aliceblue;
    border-radius: 18px;
    line-height: 50px;
    margin: 0 auto;
  }
  div:hover {
    cursor: pointer;
  }
}
.partsBox {
  display: flex;
  width: 92%;
  justify-content: space-around;
  overflow: scroll;
}
.parts {
  display: flex;
  width: 240px;
  height: 260px;
  position: relative;
  justify-content: center;
  //   background-color: #a1a1a1;
  flex-direction: column;
  img {
    width: 130px;
    margin: 0 auto;
  }
  #parts-text {
    width: 130px;
    margin: 10px auto;
  }
  #addcarbtm {
    position: absolute;
    right: 30px;
    bottom: 30px;
    font-size: 20px;
    width: 30px;
    height: 30px;
    color: #726e6e;
    text-align: center;
    line-height: 30px;
    border-radius: 50%;
    background-color: #ffe32a;
  }
}
</style>